const os = require('os');
const { Command } = require('commander');

module.exports = function CommandLineInterface({ Task, DatabaseTool }) {
	const program = new Command();

	const ChildCommand = {
		start: program.command('start', { isDefault: true }),
		dbalter: program.command('dbalter'),
		import: program.command('import')
	};

	ChildCommand.start
		.option('-c, --config', 'test config')
		.action(async opts => await Task.start());

	ChildCommand.dbalter
		.action(async opts => await DatabaseTool.dbalter());

	ChildCommand.import
		.action(async opts => await DatabaseTool.import());

	const versionData = {
		os: os.version(),
		node: process.versions
	};

	program.version(JSON.stringify(versionData));

	return program;
};